home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 2.iso / dist / fw_imlib.idb / usr / freeware / include / Imlib_private.h.z / Imlib_private.h
C/C++ Source or Header  |  2002-07-08  |  4KB  |  150 lines

  1. #include <stdio.h>
  2. #include <unistd.h>
  3. #include <stdlib.h>
  4. #include <math.h>
  5. #include <ctype.h>
  6. #include <time.h>
  7. #include <netinet/in.h>
  8. #ifdef HAVE_IPC_H
  9. #include <sys/ipc.h>
  10. #endif
  11. #ifdef HAVE_SHM_H
  12. #include <sys/shm.h>
  13. #endif
  14. #include <sys/time.h>
  15. #include <sys/types.h>
  16.  
  17. #ifdef _HAVE_STRING_H
  18. #include <string.h>
  19. #elif _HAVE_STRINGS_H
  20. #include <strings.h>
  21. #endif
  22.  
  23. #include <X11/Xlib.h>
  24. #include <X11/Xutil.h>
  25. #include <X11/Xatom.h>
  26. #include <X11/Xos.h>
  27. #ifdef HAVE_XSHM_H
  28. #include <X11/extensions/XShm.h>
  29. #endif
  30. #include <X11/extensions/shape.h>
  31. #include <X11/cursorfont.h>
  32.  
  33. #ifdef HAVE_LIBJPEG
  34. #include <jpeglib.h>
  35. #endif
  36. #ifdef HAVE_LIBPNG
  37. #include <png.h>
  38. #endif
  39. #ifdef HAVE_LIBTIFF
  40. #include <tiffio.h>
  41. #endif
  42. #ifdef HAVE_LIBGIF
  43. #include <gif_lib.h>
  44. #endif
  45.  
  46. #define BYTE_ORD_24_RGB 0
  47. #define BYTE_ORD_24_RBG 1
  48. #define BYTE_ORD_24_BRG 2
  49. #define BYTE_ORD_24_BGR 3
  50. #define BYTE_ORD_24_GRB 4
  51. #define BYTE_ORD_24_GBR 5
  52.  
  53. struct image_cache
  54.   {
  55.     char               *file;
  56.     ImlibImage         *im;
  57.     int                 refnum;
  58.     char                dirty;
  59.     struct image_cache *prev;
  60.     struct image_cache *next;
  61.   };
  62.  
  63. struct pixmap_cache
  64.   {
  65.     ImlibImage         *im;
  66.     char               *file;
  67.     char                dirty;
  68.     int                 width, height;
  69.     Pixmap              pmap;
  70.     Pixmap              shape_mask;
  71.     XImage             *xim;
  72.     XImage             *sxim;
  73.     int                 refnum;
  74.     struct pixmap_cache *prev;
  75.     struct pixmap_cache *next;
  76.   };
  77.  
  78.  
  79. int                 index_best_color_match(ImlibData * id, int *r, int *g, int *b);
  80. void                dirty_pixmaps(ImlibData * id, ImlibImage * im);
  81. void                dirty_images(ImlibData * id, ImlibImage * im);
  82. void                find_pixmap(ImlibData * id, ImlibImage * im, int width, int height, Pixmap * pmap, Pixmap * mask);
  83. ImlibImage         *find_image(ImlibData * id, char *file);
  84. void                free_pixmappmap(ImlibData * id, Pixmap pmap);
  85. void                free_image(ImlibData * id, ImlibImage * im);
  86. void                flush_image(ImlibData * id, ImlibImage * im);
  87. void                add_image(ImlibData * id, ImlibImage * im, char *file);
  88. void                add_pixmap(ImlibData * id, ImlibImage * im, int width, int height, XImage * xim, XImage * sxim);
  89. void                clean_caches(ImlibData * id);
  90. void                nullify_image(ImlibData * id, ImlibImage * im);
  91.  
  92. char               *_GetExtension(char *file);
  93. void           *_imlib_malloc_image(unsigned int w, unsigned int h);
  94.  
  95.  
  96. #ifdef HAVE_LIBJPEG
  97. unsigned char      *_LoadJPEG(ImlibData * id, FILE * f, int *w, int *h);
  98.  
  99. #endif /* HAVE_LIBJPEG */
  100. #ifdef HAVE_LIBPNG
  101. unsigned char      *_LoadPNG(ImlibData * id, FILE * f, int *w, int *h, int *t);
  102.  
  103. #endif /* HAVE_LIBPNG */
  104. #ifdef HAVE_LIBTIFF
  105. unsigned char      *_LoadTIFF(ImlibData * id, FILE *f, char *file, int *w, int *h, int *t);
  106.  
  107. #endif /* HAVE_LIBTIFF */
  108. #ifdef HAVE_LIBGIF
  109. unsigned char      *_LoadGIF(ImlibData * id, FILE *f, int *w, int *h, int *t);
  110.  
  111. #endif /* HAVE_LIBGIF */
  112. unsigned char      *_LoadBMP(ImlibData * id, FILE *f, int *w, int *h, int *t);
  113. unsigned char      *_LoadXPM(ImlibData * id, FILE *f, int *w, int *h, int *t);
  114. unsigned char      *_LoadPPM(ImlibData * id, FILE * f, int *w, int *h);
  115. int                 ispnm(FILE *f);
  116. int                 isjpeg(FILE *f);
  117. int                 ispng(FILE *f);
  118. int                 istiff(FILE *f);
  119. int                 iseim(FILE *f);
  120. int                 isgif(FILE *f);
  121. int                 isxpm(FILE *f);
  122. int                 isbmp(FILE *f);
  123.  
  124. void                calc_map_tables(ImlibData * id, ImlibImage * im);
  125.  
  126. void                _PaletteAlloc(ImlibData * id, int num, int *cols);
  127.  
  128. #define INDEX_RGB(r,g,b)  id->fast_rgb[(r<<10)|(g<<5)|(b)]
  129. #define COLOR_INDEX(i)    id->palette[i].pixel
  130. #define COLOR_RGB(r,g,b)  id->palette[INDEX_RGB(r,g,b)].pixel
  131. #define ERROR_RED(rr,i)   rr-id->palette[i].r;
  132. #define ERROR_GRN(gg,i)   gg-id->palette[i].g;
  133. #define ERROR_BLU(bb,i)   bb-id->palette[i].b;
  134.  
  135. #define DITHER_ERROR(Der1,Der2,Dex,Der,Deg,Deb) \
  136. ter=&(Der1[Dex]);\
  137. (*ter)+=(Der*7)>>4;ter++;\
  138. (*ter)+=(Deg*7)>>4;ter++;\
  139. (*ter)+=(Deb*7)>>4;\
  140. ter=&(Der2[Dex-6]);\
  141. (*ter)+=(Der*3)>>4;ter++;\
  142. (*ter)+=(Deg*3)>>4;ter++;\
  143. (*ter)+=(Deb*3)>>4;ter++;\
  144. (*ter)+=(Der*5)>>4;ter++;\
  145. (*ter)+=(Deg*5)>>4;ter++;\
  146. (*ter)+=(Deb*5)>>4;ter++;\
  147. (*ter)+=Der>>4;ter++;\
  148. (*ter)+=Deg>>4;ter++;\
  149. (*ter)+=Deb>>4;
  150.